<template>
  <el-table :data="repositories">
    <el-table-column label="仓库名称">
      <template #default="{ row }">
        <span class="fs-6 text-gray-600">{{ row.name }}</span>
        <a class="ms-2" href="javascript:void(0)" @click="handleDelete(row.id)">
          <i class="fa fa-close text-danger fs-6" />
        </a>
      </template>
    </el-table-column>
  </el-table>
</template>

<script setup lang="ts">
import type { RepositorySummary } from '@/types/business/project';
import { projectService } from '@/services/business/project.service';
import { ElMessage } from 'element-plus';

defineProps<{ repositories: RepositorySummary[] }>();
const emit = defineEmits(['deleteRepo']);

const handleDelete = async (projectRepoId: string) => {
  await projectService.deleteRepository(projectRepoId);
  emit('deleteRepo', projectRepoId);
  ElMessage.success('删除成功');
};
</script>
